﻿@** Copyright 2013 Seven Spikes Ltd. All rights reserved. (http://www.nop-templates.com)
* http://www.nop-templates.com/t/licensinginfo
*@

@using Nop.Core.Infrastructure
@model SevenSpikes.Nop.Plugins.MegaMenu.Models.MegaMenuCategoriesModels
@if (Model.CategoriesModels.Count > 0)
{
    var megaMenuSettings = EngineContext.Current.Resolve<SevenSpikes.Nop.Plugins.MegaMenu.Domain.MegaMenuSettings>();
    if (megaMenuSettings.ShowCategoriesInASingleMenuItem)
    {
        <li><a href="#">@T("SevenSpikes.MegaMenu.Admin.Settings.MenuItemNameValue")</a>
            <div class="dropdown categories">
                <div class="row">
                    <div class="box">
                        <div class="title">
                            <strong>@T("SevenSpikes.MegaMenu.Admin.Settings.CategoriesColumnTitleValue")</strong>
                        </div>
                        <ul>
                            @foreach (var category in Model.CategoriesModels)
                            {
                                <li>
                                    <a href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@category.CategoryModel.Name</a>
                                </li>
                            }
                        </ul>
                    </div><!--box-->
                    @if (megaMenuSettings.ShowManufacturersInCategories)
                    {
                        <div class="box">
                            <div class="title">
                                <strong>@T("SevenSpikes.MegaMenu.Admin.Settings.ManufacturersColumnTitleValue")</strong>
                            </div>
                            <ul>
                                @{var manufacturerCounter = 0;}
                                @foreach (var category in Model.CategoriesModels)
                                {
                                    if (manufacturerCounter == megaMenuSettings.NumberOfManufacturersInCategories && megaMenuSettings.NumberOfManufacturersInCategories != 0)
                                    {
                                        break;
                                    }

                                    foreach (var categoryManufacturer in category.CategoryManufacturers)
                                    {
                                        if (manufacturerCounter == megaMenuSettings.NumberOfManufacturersInCategories && megaMenuSettings.NumberOfManufacturersInCategories != 0)
                                        {
                                            <li>
                                                <a class="view-all" href="@Url.RouteUrl("ManufacturerList")">@T("SevenSpikes.MegaMenu.ViewAllManufacturers")</a>
                                            </li>
                                            break;
                                        }
                            
                                    <li>
                                        <a href="@Url.RouteUrl("Manufacturer", new { SeName = categoryManufacturer.SeName })">@categoryManufacturer.Name</a>
                                    </li>
                                        
                                    manufacturerCounter++;
                                    }
                                }
                            </ul>
                        </div>
                        <!--box-->
                    }
                @*<div class="box">
                    @Html.Action("WidgetsByZone", "Widget", new { widgetZone = "mega_menu_category_template_without_pictures_single_menu_item" })
                </div><!--box-->*@
                </div><!--row-->
            </div><!--dropdown-->
        </li>
    }
    else
    {
        foreach (var category in Model.CategoriesModels)
        {
            <li><a href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@category.CategoryModel.Name</a>
                @if (category.SubCategories.Count > 0)
                {
                    <div class="dropdown categories">
                        <div class="row">
                            <div class="box">
                                <div class="title">
                                    <strong>@T("SevenSpikes.MegaMenu.Admin.Settings.CategoriesColumnTitleValue")</strong>
                                </div>
                                <ul>
                                    @{
                                        var categoriesCounter = 0;
                                        foreach (var subCategory in category.SubCategories)
                                        {
                                            categoriesCounter++;
                                
                                            <li>
                                                <a href="@Url.RouteUrl("Category", new { SeName = subCategory.CategoryModel.SeName })">@subCategory.CategoryModel.Name</a>
                                            </li>
                                
                                
                                            if (categoriesCounter == megaMenuSettings.NumberOfCategories && megaMenuSettings.NumberOfCategories != 0)
                                            {
                                                <li>
                                                    <a class="view-all" href="@Url.RouteUrl("Category", new { SeName = category.CategoryModel.SeName })">@T("SevenSpikes.MegaMenu.ViewAllCategories")</a>
                                                </li>
                                
                                                break;
                                            }
                        
                                        }
                                    }
                                </ul>
                            </div><!--box-->
                            @if (megaMenuSettings.ShowManufacturersInCategories && category.CategoryManufacturers.Count > 0)
                            {
                                <div class="box">
                                    <div class="title">
                                        <strong>@T("SevenSpikes.MegaMenu.Admin.Settings.ManufacturersColumnTitleValue")</strong>
                                    </div>
                                    <ul>
                                        @{var manufacturerCounter = 0;}
                                        @foreach (var categoryManufacturer in category.CategoryManufacturers)
                                        {
                                            if (manufacturerCounter == megaMenuSettings.NumberOfManufacturersInCategories && megaMenuSettings.NumberOfManufacturersInCategories != 0)
                                            {
                                                <li>
                                                    <a class="view-all" href="@Url.RouteUrl("ManufacturerList")">@T("SevenSpikes.MegaMenu.ViewAllManufacturers")</a>
                                                </li>
                                            
                                                break;
                                            }
                            
                                            <li>
                                                <a href="@Url.RouteUrl("Manufacturer", new { SeName = categoryManufacturer.SeName })">@categoryManufacturer.Name</a>
                                            </li>
                            
                                            manufacturerCounter++;
                                        }
                                    </ul>
                                </div><!--box-->
                            }
                        </div><!--row-->
                    </div><!--dropdown-->
                }
            </li>
        }
    }
}
